package com.mesmileAI.controller;

import com.mesmileAI.entity.ApiConfig;
import com.mesmileAI.service.ApiConfigService;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.*;

//使用代理配置
@RestController
@AllArgsConstructor
@Slf4j
@RequestMapping("/apiConfig")
public class ApiConfigController {

    @Resource
    ApiConfigService service;

    //详情
    @GetMapping("/detail/{id}")
    public ApiConfig detail(@PathVariable String id){
        return service.getById(id);
    }


    /**
     * 列表
     */
    @GetMapping("/list")
    public List<ApiConfig> list() {
        return service.list();
    }
    /*
     *新建
     */
    @PutMapping("/save")
    public boolean save(@RequestBody ApiConfig apiConfig) {
        Date date = new Date();
        apiConfig.setCreateTime(date);
        service.save(apiConfig);
        return true;
    }

    /**
     *更新
     */
    @PostMapping("/update")
    public boolean update(@RequestBody ApiConfig apiConfig) {
        service.updateById(apiConfig);
        return true;
    }
    /**
     *删除
     */
    @DeleteMapping("/delete/{id}")
    public Boolean delete(@PathVariable String id){
        service.removeById(id);
        return true;
    }


}
